package com.itheima.file;

import java.io.File;
import java.io.IOException;

public class FileDemo04 {
    public static void main(String[] args) throws IOException {
        File file = new File("F:\\IOfile");
        deleteDir(file);

    }

    private static void deleteDir(File file) {
        //1.进入该路径的文件夹
        File[] files = file.listFiles();

        //2.遍历里面的内容
        for (File path : files) {
            if (path.isFile()){
                //3.判断是文件的话就直接删除
                path.delete();
            }else if (path.isDirectory()){
                //4.是文件夹的话就递归
                deleteDir(path);
            }
        }
        //5. 最后删除自己
        file.delete();
    }

}
